﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoolERP_Entities;

namespace CoolERP_DAL
{
    public interface IZL_CWDAL : IDAL<ZL_CW>
    {
    }

    public class ZL_CWDAL : BaseDAL<ZL_CW>, IZL_CWDAL
    {
        public ZL_CWDAL(IUnitOfWork context)
            : base(context)
        {
        }

        public override IList<ZL_CW> GetPagerList(Func<ZL_CW, bool> exp, string orderExpr, int? pageIndex, int pageSize, out int totalCount)
        {
            IQueryable<ZL_CW> result = dataContext.ZL_CW.Include("ZL_CK");
            if (exp != null)
                result = result.Where(exp).AsQueryable();
            totalCount = result.Count();
            if (!string.IsNullOrEmpty(orderExpr))
                result = SortingExtensions.OrderUsingSortExpression(result, orderExpr);
            if (pageIndex == null)
                return result.ToList();
            else
                return result.Skip(Convert.ToInt32(--pageIndex) * pageSize).Take(pageSize).ToList();
        }
    }
}
